import pymysql


def DB(user,password):
    db = pymysql.connect(host='localhost',
                         user='root',
                         password='root517230.',
                         database='book')

    cursor = db.cursor()

    sql = 'select * from user where username = "{}" and password = {}'.format(user, password)

    try:
        cursor.execute(sql)
        results = cursor.fetchall()
        if not results:
            return 0
        else:
            return 1
    except:
        return 0
    db.close()

